<?php
require "hrfuns.php";
Valid_Client();

if (isset($_POST["Action"])) {
    $iSQL = GetSQL();

    switch ($_POST["Action"]) {
    case "Add":
        $sqlstr = "insert into eminfo_t values("
            . "'" . $_POST["EmId"] . "'"
            . ", '" . $_POST["EmName"] . "'"
            . ", " . $_POST["EmDepart"]
            . ", '" . $_POST["EmEnter"] . "'"
            . ", '" . $_POST["EmClass"] . "'" 
            . ", '" . $_POST["EmBirth"] . "'"
            . ", '" . $_POST["EmGender"] . "'"
            . ")";

        break;

    case "Delete":
        $sqlstr = "delete from eminfo_t"
                . " where em_id = '". $_POST["EmId"] . "'";
        break;

    case "Modify":
        $sqlstr = "update eminfo_t"
                . " set em_name='" . $_POST["EmName"] . "'"
                . ", em_depart_id=" . $_POST["EmDepart"]
                . ", em_enter='" . $_POST["EmEnter"] . "'"
		. ", em_class='" . $_POST["EmClass"] . "'"
                . ", em_birth='" . $_POST["EmBirth"] . "'"
                . ", em_gender='" . $_POST["EmGender"] . "'"
                . " where em_id = '". $_POST["EmId"] . "'";
        break;
    default:
        exit;
    }

    if (isset($sqlstr) && strlen($sqlstr) > 0) {
        if (! $iSQL->query($sqlstr)) 
            echo $_POST["Action"] . "Failed: $sqlstr";
    }

    $iSQL->close();
}
?>
